package com.jiang.jixiang.ui.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import androidx.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.jiang.jixiang.R;
import com.ws.universal.tools.Constants;
import com.ws.universal.tools.base.LanguageBean;
import com.ws.universal.tools.utils.CacheUtils;

public class LanguageAdapter extends BaseQuickAdapter<LanguageBean, BaseViewHolder> {
    private int type;

    public LanguageAdapter(int type) {
        super(type == 1 ? R.layout.item_language : R.layout.item_language2);
        this.type = type;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, LanguageBean bean) {
        holder.setText(R.id.tvItemName, bean.getLanguageName());
        ImageView imgItemChoose = holder.findView(R.id.imgItemChoose);
        RelativeLayout rlItemLayout = holder.findView(R.id.rlItemLayout);
        /*if (!CacheUtils.getBoolean(Constants.isFristInstall)) {
            ImageView imgItemCountry = holder.findView(R.id.imgItemCountry);
            if (getItemPosition(bean) == 0) {
                imgItemCountry.setImageResource(R.mipmap.icon_language_en);
            } else if (getItemPosition(bean) == 1) {
                imgItemCountry.setImageResource(R.mipmap.icon_language_zh);
            }
        }*/
        if (type == 1) {
            if (bean.isChoose()) {
                rlItemLayout.setBackground(getContext().getDrawable(R.drawable.language_choose));
                imgItemChoose.setVisibility(View.VISIBLE);
            } else {
                rlItemLayout.setBackground(null);
                imgItemChoose.setVisibility(View.GONE);
            }
        } else {
            if (bean.isChoose()) {
                imgItemChoose.setImageResource(R.mipmap.icon_lang_chooseed);
            } else {
                imgItemChoose.setImageResource(R.mipmap.icon_lang_choose);
            }
            rlItemLayout.setBackground(getContext().getDrawable(R.drawable.language_chooseed));
        }

    }
}
